package com.feituan.core.exception;

import com.feituan.core.error.SystemCode;
import lombok.ToString;

@ToString(callSuper = true)
public class BusinessException extends RuntimeException {

    private SystemCode systemCode;

    private String extMessage;

    public BusinessException(SystemCode systemCode) {
        this(systemCode, null, null);
    }

    public BusinessException(SystemCode systemCode, String message) {
        this(systemCode, message, null);
    }

    public BusinessException(SystemCode systemCode, Throwable cause) {
        this(systemCode, null, cause);
    }

    public BusinessException(SystemCode systemCode, String message, Throwable cause) {
        super(systemCode.getMessage(), cause);
        this.extMessage = message;
        this.systemCode = systemCode;
    }

    public SystemCode getSystemCode() {
        return systemCode;
    }

    public String getExtMessage() {
        return extMessage;
    }
}
